package com.decent.ejfadmin.user.service.impl;

import com.decent.ejfadmin.common.bean.Page;
import com.decent.ejfadmin.common.bean.RecommendUser;
import com.decent.ejfadmin.user.dao.RecommendUserDao;
import com.decent.ejfadmin.user.service.RecommendUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;

/**
 * 推荐返利用户列表
 *
 * @author weicx
 * @date 2018/07/28
 */
@Service
public class RecommendUserServiceImpl implements RecommendUserService {
    @Autowired
    private RecommendUserDao recommendUserDao;

    /**
     * 分页查询推荐返利用户列表
     *
     * @param recommendUser 返利用户实体
     * @param page          分页组件
     * @param startTime     查询开始时间
     * @param endTime       查询结束时间
     * @return
     */
    @Override
    public Page queryRecommendUser(RecommendUser recommendUser, Page page, String startTime, String endTime) {
        int total = recommendUserDao.queryRecommendUserCount(recommendUser, startTime, endTime);
        page.setTotal(total);
        if (total == 0) {
            page.setResultList(new ArrayList<>());
        } else {
            page.setResultList(recommendUserDao.queryRecommendUser(recommendUser, page, startTime, endTime));
        }
        return page;
    }
}
